home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / prog_c / lsdoor09.zip / LORD.H < prev    next >
C/C++ Source or Header  |  1996-06-03  |  17KB  |  397 lines

  1. // LORD Routines for LsDoor SDK...
  2.  
  3. //   LORD stands for Legend Of the Red Dragon, a very popular online BBS
  4. // door game created by Seth Robinson (a.k.a. Seth Able).  LORD provides a
  5. // mechanism for programmers to create IGM programs - [I]n [G]ame [M]odules
  6. // which allow you to add to the LORD game with your own creations.
  7.  
  8. //   To create a LORD IGM using the LsDoor SDK, the main requirement is that
  9. // you call the LORD_Init() function instead of DoorInit().  LORD_Init()
  10. // does most of the same things that DoorInit() does, including setting up
  11. // the status line and serial port.  All of the other LsDoor functions
  12. // should work normally in a LORD IGM.
  13.  
  14. /*
  15.  
  16.    For a program to be considered an official LORD IGM by Seth Able it
  17.    must meet these requirements:
  18.  
  19.    1. It reads *NO* external drop file.  It gets all its data from the
  20.       Info.* and Node*.Dat files.  In the LsDoor SDK, this is all taken
  21.       care of by the LORD_Init() function below.
  22.  
  23.    2. It has options to install *AND* uninstall itself.  Part of this task
  24.       is handled by the LORD_Install() and LORD_UnInstall() functions
  25.       below, however it is up to you to write a utility or installation
  26.       program to call these functions.  In addition, any special options
  27.       which your program needs are your responsibility.  Only the internals
  28.       of LORD are taken care of by the LsDoor SDK.
  29.  
  30.    3. The top line of the FILE_ID.DIZ reads like so:
  31.       <NAME & VERSION OF YOUR PROGRAM> LORD IGM
  32.       You may decorate it if you like.
  33.  
  34.      ***
  35.    Statement from Seth A. Robinson:  You have my permission to build
  36.    add-ons, editers, whatever - BUT, if you decide to charge money for
  37.    them I would appreciate it if you would upload me your file
  38.    privately, let me evualuate it and see if it deserves my stamp of
  39.    approval.
  40.  
  41.    That's right, I'm not against others making money off their mods, in
  42.    fact, I don't demand any percentage whatsoever.  God knows I've made
  43.    much more than I deserve already.  Just try not to charge more than
  44.    I do for LORD itself, k?
  45.  
  46.    Also, in ANY util for LORD, be sure to give some credit to ME! <G>
  47.      ***
  48.  
  49. */
  50.  
  51.  
  52. #ifndef __LORD_HEADER__
  53. #define __LORD_HEADER__
  54.  
  55. test LORD_Init( char *path );   // See below
  56. test LORD_SetPath( char *path );// Returns same as LORD_Init()
  57.   // For your program to use any of the LORD_ Functions, you must first
  58.   // call one of these two functions.  If your program is for local-use
  59.   // only (such as an installation utility), use LORD_SetPath().  If your
  60.   // program is being run via LORD, use LORD_Init().
  61.   // Both functions will exit the program on general failure, return false
  62.   // if LORD could not be found in the given path (or version < 3.53a),
  63.   // or return true if successful.
  64.  
  65. char *WithLORDPath( char * );
  66.   // This function will return "C:\Lord\****" where **** is the (char *).
  67.  
  68. int LORD_read( char *filename, long record_number, void *buffer, unsigned len );
  69. int LORD_write( char *filename, long record_number, void *buffer, unsigned len );
  70.   // These two functions work much like the C functions read() and write().
  71.   // They use the same return value as read() and write().
  72.  
  73. short LORD_open( char *filename, int access );
  74. FILE *LORD_fopen( char *filename, char *mode );
  75. void  LORD_close( char *filename, short handle );
  76. void  LORD_fclose( char *filename, FILE *handle );
  77.   // The above functions open and close LORD's .DAT files, blocking access
  78.   // to any other nodes while the file is open.  *** WARNING:  Never keep
  79.   // a LORD data file open for more than 3 seconds!
  80.  
  81. void LORD_ExitSleep( char *msg, char *cmdline );
  82.   // This function exits your program and LORD.  The next time the user
  83.   // enters LORD, the IGM specified in cmdline will be executed (after
  84.   // the user's mail and such.)  The format for (char *)cmdline is the
  85.   // same as that for LORD_Install()'s cmdline paramater, however you might
  86.   // want to add a command line option such as /RET to indicate to your
  87.   // program at that time that the user is returning from their slumber.
  88.   // To other users, (char *)msg will show up until the user next enters
  89.   // LORD (and your IGM.)  Example use:
  90.   //
  91.   // LORD_ExitSleep( "is sleeping in the heavens.",
  92.   //                   "C:\MyGame\Cloud.Exe /N* /RET" );
  93.   //
  94.  
  95. test LORD_FixBadWords( char *str );
  96.   // This function checks LORD's BADWORDS.DAT file against *str and replaces
  97.   // any bad words.
  98.  
  99. void LORD_Install( char *msg, char *cmdline );
  100. void LORD_UnInstall( char *cmdline );
  101.   // These two functions install or uninstall your IGM into LORD.  They
  102.   // modify the 3RDPARTY.DAT file.  *msg is the text string that will show
  103.   // up in LORD's "Other Places" listing (it can include ` color codes.)
  104.   // *cmdline is the command line LORD should execute to run your program.
  105.   // This will usually be the path and filename of your EXE file.  You may
  106.   // use asterik (*) symbols to be replaced by the current node number.
  107.   // For LORD_UnInstall(), what you specify from *cmdline will be searched
  108.   // for.  If a match is found in 3RDPARTY.DAT, it is removed.  Examples:
  109.   //
  110.   // LORD_Install( "`0V`2isit `0H`2eaven", "C:\\IGM\\Mine.Exe /N*" );
  111.   // LORD_UnInstall( "Mine.Exe" );
  112.   //
  113.  
  114. struct LORDPlayer
  115. {
  116.   unsigned short account;    // Account number
  117.   unsigned char handle[40];  // LORD Handle
  118.   test fairy;                // Do they have a fairy with them?
  119.   test lord_registered;      // (True/False) Is LORD registered?
  120.   test clean;                // (True/False) Clean Mode
  121. } global LORDPlayer;
  122.  
  123.   // The LORDPlayer structure is completely filled by LORD_Init().
  124.   //
  125.   // Also valid in LORD IGM's and LOCAL mode:
  126.   //
  127.   //   user.real, terminal, drop.terminal, redirect, drop.redirect,
  128.   //   Valid, but from LORD and not BBS:  user.timelimit, user.timeused
  129.   //   node.ID.num, node.comport, node.irq, node.base, node.baud, nodeid.baud
  130.   //
  131.   //
  132.   // Valid in LORD IGM's only:
  133.   //
  134.   //   master.bbs_name
  135.   //
  136.  
  137.   /***  LORD Data  ***/
  138.  
  139.   //   There is no requirement that you must access any of the LORD records.
  140.   // You can modify the current user (or any user)'s account using mail
  141.   // (see "Mail Services" below.)  However, if you do want to mess around
  142.   // with a user's account, or an enemy from the forest, here's the tools.
  143.  
  144.  
  145.   //
  146.   // Use the LORD_read() and LORD_write() functions to access these records.
  147.   // For example, to read account #2 into LORDAccount, use this:
  148.   //
  149.   // if( LORD_read( "Player.Dat", 2, &LORDAccount, sizeof(LORDAccount) )
  150.   //       < sizeof(LORDAccount) )
  151.   //   errorHandler();
  152.   //
  153.   // Note:  The record number always starts at 0 (there is always a valid
  154.   // record numbered 0.)
  155.   //
  156.   // ** LORD STRINGS:
  157.   //
  158.   //   LORD uses Pascal style strings.  In C, a string is a character array
  159.   // which ends in a 0 to mark the string's end.  The 0 is also called the
  160.   // NULL-Terminator, a NULL character, a '\0', etc.  In Pascal (which is
  161.   // what LORD uses) a string is also a character array, but there is no
  162.   // terminator character, and the first character in the array is a number
  163.   // giving the string's entire length.  We have worked around this by
  164.   // providing a lxxxx variable and a xxxx variable for each string.  Use
  165.   // the functions below to translate between them.
  166.  
  167. char *LORD_toC( char len, char *string );
  168.   // For some insight about these two functions, see the above comment.
  169.   // To translating from C to Pascal, use strlen().  Examples:
  170.   //
  171.   /*                     // Pascal to C
  172.      char mine[ 80 ];
  173.      strcpy( mine, LORD_toC(lnames,names) );
  174.   */
  175.   /*                     // C to Pascal
  176.      char mine[ 80 ] = "My C String";
  177.      strcpy( LORDAccount.names, mine );
  178.      LORDAccount.lnames = strlen( mine );
  179.   */
  180.  
  181.   //  Thanks to John Hutton for helping in translating these records from
  182.   //  Pascal to C.  I could have done it myself, but thanks to him I can
  183.   //  have a day off.
  184.  
  185. typedef struct           // LORDAccount - Records in PLAYER.DAT
  186. {
  187.   char lnames;           // length for names (See above)
  188.   char names[20];        // array for names
  189.   char lreal_names;      // length for real names
  190.   char real_names[50];   // array for real names
  191.   short hit_points;      // hit points
  192.   short bad;             // not used
  193.   short rate;            // not used
  194.   short hit_max;         // maximum hit points
  195.   short weapon_num;      // weapon number
  196.   char lweapon;          // length of weapon name
  197.   char weapon[20];       // array for weapon name
  198.   short seen_master;     // 5 if seen Master, else 0
  199.   short fights_left;     // forest fights left
  200.   short human_left;      // human fights left
  201.   long gold;             // gold in hand
  202.   long bank;             // gold in bank
  203.   short def;             // total defense points
  204.   short strength;        // total strength
  205.   short charm;           // good looking meter
  206.   short seen_dragon;     // seen dragon? 5 if yes else 0
  207.   short seen_violet;     // seen violet? 5 if yes else 0
  208.   short level;           // level of player
  209.   ushort time;           // day # that player last played on
  210.   char larm;             // length of armour name
  211.   char arm[20];          // armour name
  212.   short arm_num;         // armour number
  213.   char dead;             // player dead? 5 if yes else 0
  214.   char inn;              // player sleeping at inn? 5 if yes else 0
  215.   short gem;             // # of gems on hand
  216.   long exp;              // experience
  217.   char sex;              // gender, 5 if female else 0
  218.   char seen_bard;        // seen bard? 5 if yes else 0
  219.   short last_alive_time; // day # player was last reincarnated on
  220.   short lays;            // players lays stat
  221.   short why;             // not used yet
  222.   test on_now;           // is player on?
  223.   short m_time;          // day on_now stat wa last used
  224.   char ltime_on;         // length of time_on string
  225.   char time_on[5];       // time player logged on in HH:MM format
  226.   char _class;           // class, should be 1, 2 or 3
  227.   short extra;           // if 1, player has a horse
  228.   char llove;            // length of love string
  229.   char love[25];         // not used - may be for inter player marriage
  230.   short married;         // who player is married to, -1 if not married
  231.   short kids;            // # of kids
  232.   short king;            // # of times player has won game
  233.   char skillw;           // number of Death Knight skill points
  234.   char skillm;           // number of Mystical Skills points
  235.   char skillt;           // number of Thieving Skills points
  236.   char levelw;           // number of Death Knight skill uses left today
  237.   char levelm;           // number of Mystical Skill uses left today
  238.   char levelt;           // number of Thieving Skill usues left today
  239.   test inn_random;       // not used yet
  240.   short married_to;      // same as Married?
  241.   long v1;
  242.   short v2;              // number of player kills
  243.   short v3;              // if 5, 'weird' event in forest will happen
  244.   test v4;               // has player done 'special' for that day?
  245.   char v5;               // has player flirted with another player today 5
  246.   char new_stat1;
  247.   char new_stat2;
  248.   char new_stat3;
  249. } LORDAccount;
  250.  
  251. typedef struct          // LORDMonster - Records in LENEMY.DAT
  252. {
  253.   char lname;           // length for name
  254.   char name[60];        // name
  255.   long strength;
  256.   long gold;
  257.   char lweapon;         // length for name of weapon
  258.   char weapon[60];      // name of weapon
  259.   long exp_points;
  260.   long hit_points;
  261.   char ldeath;          // length for death string
  262.   char death[100];      // shown when monster is killed by power move
  263. } LORDMonster;
  264.  
  265.   /*
  266. short armor_strength[] = { 0, 1, 3, 10, 15, 25, 35, 50, 75, 100, 150, 225,
  267.             300, 400, 600, 1000};
  268.  
  269. short weapon_strength[] = { 0, 5, 10, 20, 30, 40, 60, 80, 120, 180, 250, 350,
  270.              500, 800, 1200, 1800};
  271.   */
  272.  
  273.  
  274.   /***  Mail Services  ***/
  275.  
  276.   //   Use the C++ class LORD_Mail to send mail to LORD users.  For C
  277.   // programmers, follow the examples below for some help.  You can also
  278.   // use LORD's mail services to modify a user, such as giving them
  279.   // experience, charm, or taking away different things.  You can also send
  280.   // romantic mail and the like.  You can send a message to any user, using
  281.   // their account number.
  282.  
  283.  
  284.   //
  285.   // class LORD_Mail:
  286.   //
  287.   //   * SetNone() only needs to be called to clear one of the other
  288.   // settings.  If you have not called any SetXXX() functions, the default
  289.   // is SetNone().
  290.   //
  291.   //   * A LORD_Mail object should never exist for more than 3 seconds!
  292.   //
  293.   // Examples:
  294.   /*
  295.      LORD_Mail mess( 12 );
  296.      mess.AddText( "Thats all folks." );
  297.   */
  298.   //   In the above, the message "Thats all folks." will be sent to the
  299.   // reader, user #12.  The first line "creates an object".  C Programmers
  300.   // can generally think of an object as "just another variable".  But keep
  301.   // in mind that the time the variable (or object) is created to the time
  302.   // that it is destroyed should not exceed 3 seconds.  The most common way
  303.   // for an object to be destroyed is for it to "go out of scope".  For
  304.   // example:
  305.   /*
  306.      if( somevar == 2 )
  307.      {
  308.        LORD_Mail mess( 6 );
  309.        mess.AddText( "Just saying hi." );
  310.      }
  311.      // At this point the local variable 'mess' will have been destroyed,
  312.      // "if" it was ever created at all.
  313.   */
  314.   // More examples:
  315.   /*
  316.      LORD_Mail mess( 22 );
  317.      mess.AddText( "`%  Message from THE DEMON..." );
  318.      mess.AddText( "`0-=-=-=-=-=-=-=-=-=-=-=-" );
  319.      mess.AddText( "  I give you these things to aid thee in thy quest." );
  320.      mess.AddText( "In exchange, I take from thee 400 experience points." );
  321.      mess.AddText( "" );
  322.      mess.AddCharm();
  323.      mess.AddSkill( 4 );
  324.      mess.AddBank( 45000 );
  325.      mess.AddExp( -400 );
  326.   */
  327.   //   The above example demonstrates that the default color for AddText()
  328.   // is dark green (2).  It also shows that you can use negative numbers
  329.   // in any of the AddXXX functions except those that take an 'unsigned'
  330.   // value, such as AddSkill().
  331.   /*
  332.      LORD_Mail *m = new LORD_Mail( 15 );
  333.      m->AddText( "An anonymous person wants dinner with you." );
  334.      m->SetDinner( 25 );
  335.      delete m;
  336.   */
  337.   //   The above demonstrates a different way to create an object which lets
  338.   // you control when it is deleted.  It also shows how to use the SetXXXX()
  339.   // functions.  Note that the SetXXXX() functions may be used anywhere
  340.   // between the creation and destruction of the object.  Only one SetXXXX()
  341.   // can be used in the end, calling a second SetXXXX() function overrides
  342.   // any previous calls.
  343.   //
  344.  
  345.  
  346. class LORD_Mail
  347. {
  348. private:
  349.   FILE *handle;
  350.   char space[80];
  351.  
  352.   char endCode;
  353.   unsigned short account;
  354.  
  355.   static char EndCodes[8];
  356.  
  357.   unsigned short to_acc;
  358.  
  359.   void Add( char *line );
  360. public:
  361.   ~LORD_Mail();
  362.  
  363.   LORD_Mail( unsigned short to_account );
  364.  
  365.   void SetNone( void ){ endCode = 0; }
  366.   void SetReply( unsigned short to ){    endCode = 1; account = to; }
  367.   void SetFlirt( unsigned short with ){  endCode = 2; account = with; }
  368.   void SetKiss( unsigned short with ){   endCode = 3; account = with; }
  369.   void SetDinner( unsigned short with ){ endCode = 4; account = with; }
  370.   void SetSleep( unsigned short with ){  endCode = 5; account = with; }
  371.   void SetPropose( unsigned short to ){  endCode = 6; account = to; }
  372.  
  373.   void AddText( char *line );
  374.   void AddMoney( long amount ){ sprintf(space,"`G%li",amount); Add(space); }
  375.   void AddBank( long amount ){ sprintf(space,"`b%li",amount); Add(space); }
  376.   void AddExp( long experience ){ sprintf(space,"`E%li",experience); Add(space); }
  377.   void AddCharm( void ){ Add("`}"); }
  378.   void SetCharm( ushort charm ){ sprintf(space,"`+%u",charm); Add(space); }
  379.   void AddLay( void ){ Add("`{"); }
  380.   void AddKid( void ){ Add("`K"); }
  381.   void AddStrength( long amount ){ sprintf(space,"`M%li",amount); Add(space); }
  382.   void AddDefense( long amount ){ sprintf(space,"`D%li",amount); Add(space); }
  383.   void AddForest( short fights ){ sprintf(space,"`,%i",fights); Add(space); }
  384.   void AddUser( short fights ){ sprintf(space,"`:%i",fights); Add(space); }
  385.   void AddHPMax( short amount ){ sprintf(space,"`;%i",amount); Add(space); }
  386.   void AddSkill( ushort points ){ sprintf(space,"`S%u",points); Add(space); }
  387.   void Marry( short to ){ sprintf(space,"`?%i",to); Add(space); }
  388.   void Unmarry( void ){ Marry( -1 ); }
  389.   void AddCLS( void ){ Add("`c"); }
  390. };
  391.  
  392.  
  393. #endif
  394.  
  395. // End of LORD.H
  396.  
  397.